<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body class="layui-anim layui-anim-up">
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
    <a class="layui-btn layui-btn-primary layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:38px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
            <input type="text" name="teaNo"  placeholder="请输入教师编号" id="teaNo" autocomplete="off" class="layui-input" style="width: 160px;">
            <input type="button" class="layui-btn" lay-submit="" lay-filter="search" id="searchByNo" value="搜索"
                   onclick="searchTeaByNo()"/>
            <input type="text" name="teaName"  placeholder="请输入教师姓名" id="teaName" autocomplete="off" class="layui-input">
            <input type="button" class="layui-btn" lay-submit="" lay-filter="search" id="searchByName" value="搜索"
                   onclick="searchTeaByName()"/>
            <input type="text" name="teaDl"  placeholder="请输入教师专业" id="teaDl" autocomplete="off" class="layui-input" style="width: 160px;">
            <input type="button" class="layui-btn" lay-submit="" lay-filter="search" id="searchByDis" value="搜索"
                   onclick="searchTeaByDl()"/>
            <input type="text" name="teaMail"  placeholder="请输入教师邮箱" id="teaMail" autocomplete="off" class="layui-input"style="width: 140px;">
            <input type="button" class="layui-btn" lay-submit="" lay-filter="search" id="searchByMail" value="搜索"
                   onclick="searchTeaByMail()"/>
            <br><br>
            <input type="button" class="layui-btn" id="showAll" onclick="showAllTea()" value="查看所有"/>
        </form>
    </div>
    <xblock>
<!--        <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>-->
        <button class="layui-btn" onclick="x_admin_show('添加教师用户','./addTea.html',600,400)"><i class="layui-icon"></i>添加</button>
        <span class="x-right" style="line-height:40px">本次搜索总共搜索到<b><font size="4px" color="red" id="teacherNum">这里填入搜索结果的统计数量</font></b>条数据</span>
    </xblock>

    <table class="layui-table">
        <thead>
        <tr>
<!--            <th width="4%">-->
<!--                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>-->
<!--            </th>-->
            <th>ID</th>
            <th>用户名</th>
            <th>密码</th>
            <th>专业</th>
            <th>Email</th>
            <th width="18%">操作</th>
        </tr>
        </thead>
        <tr id="teacher"></tr>
        <td id="button"></td>
        <tr id="teacher0">
            <td id="teaNo0"></td>
            <td id="teaName0"></td>
            <td id="teaPwd0"></td>
            <td id="teaDl0"></td>
            <td id="teaMail0"></td>
            <td class="td-status" id="button0">
                <a title="tea0" id="change" class="layui-btn layui-btn-sm layui-btn-warm" onclick="x_admin_show_sendId(this.title,'changeTea.html',600,620)"  href="javascript:;">
                    修改个人信息
                </a>
                <a title="tea0" id="delete" class="layui-btn layui-btn-sm layui-btn-danger" id="delete" onclick="member_del(this,this.title)" href="javascript:;">
                    删除用户
                </a>
            </td>
        </tr>
        <tbody id="teacherList0">

        </tbody>
        <tbody id="teacherList">

        </tbody>
    </table>

    </div>

    <input id="Id" type="hidden" name="teaId" value="">

</div>

<script type="text/javascript">
    var manaNo=sessionStorage.getItem("manaNo");
    function showAllTea(){
    $.ajax({
        url: "/manager/gettealist",
        type : "post",
        async: false,
        dataType: "json",
        data : {manaNo:manaNo},
        // contentType: "application/json",
        success: function (data) {
            console.log("请求成功");
            var i=0;
            for (;;i++){
                if (data[i]){
                    if (i!==0){
                        var teacher=document.getElementById("teacher").cloneNode(true);
                        teacher.id="tea"+i;
                        var teaNo=document.getElementById("teaNo0").cloneNode(true);
                        var teaName=document.getElementById("teaName0").cloneNode(true);
                        var teaPwd=document.getElementById("teaPwd0").cloneNode(true);
                        var teaDl=document.getElementById("teaDl0").cloneNode(true);
                        var teaMail=document.getElementById("teaMail0").cloneNode(true);

                        teaNo.innerHTML=data[i].teaNo;
                        sessionStorage.setItem("tea"+i,data[i].teaNo);
                        teaName.innerHTML=data[i].teaName;
                        teaPwd.innerHTML=data[i].teaPwd;
                        teaDl.innerHTML=data[i].teaDiscipline;
                        teaMail.innerHTML=data[i].teaMail;

                        teacher.appendChild(teaNo);
                        teacher.appendChild(teaName);
                        teacher.appendChild(teaPwd);
                        teacher.appendChild(teaDl);
                        teacher.appendChild(teaMail);

                        var button=document.getElementById("button").cloneNode(true);
                        var change=document.getElementById("change").cloneNode(true);
                        var del=document.getElementById("delete").cloneNode(true);
                        change.title="tea"+i;
                        del.title="tea"+i;

                        button.appendChild(change);
                        button.appendChild(del);
                        teacher.appendChild(button);

                        document.getElementById("teacherList0").appendChild(teacher);
                        var j=i+1;
                        document.getElementById("teacherNum").innerHTML=j;
                    }
                    else if (i==0){
                        sessionStorage.setItem('tea0',data[i].teaNo);
                        document.getElementById("teacherNum").innerHTML=i;
                        document.getElementById("teaNo0").innerHTML=data[0].teaNo;
                        document.getElementById("teaName0").innerHTML=data[0].teaName;
                        document.getElementById("teaPwd0").innerHTML=data[0].teaPwd;
                        document.getElementById("teaDl0").innerHTML=data[0].teaDiscipline;
                        document.getElementById("teaMail0").innerHTML=data[0].teaMail;
                    }
                }
                else break;
            }
            document.getElementById("teacherList").innerHTML=null;
            for (i=1;;i++){
                if (data[i]){
                    document.getElementById("teacherList").appendChild(document.getElementById("tea"+i));
                }
                else break;
            }
            document.getElementById("teacherList0").innerHTML=null;
        },
        error: function (data) {
            console.log("请求失败");
        }
    });
    }
    function searchTeaByNo(){
        var id=$("#teaNo").val();
        $.ajax({
            url: "/teacher/getteabyteano",
            type : "post",
            async: false,
            dataType: "json",
            data : {teaNo:id},
            // contentType: "application/json",
            success: function (data) {
                console.log("请求成功");
                var i=0;
                for (;;i++){
                    if (data[i]){
                        if (i!==0){
                            var teacher=document.getElementById("teacher").cloneNode(true);
                            teacher.id="tea"+i;
                            var teaNo=document.getElementById("teaNo0").cloneNode(true);
                            var teaName=document.getElementById("teaName0").cloneNode(true);
                            var teaPwd=document.getElementById("teaPwd0").cloneNode(true);
                            var teaDl=document.getElementById("teaDl0").cloneNode(true);
                            var teaMail=document.getElementById("teaMail0").cloneNode(true);

                            teaNo.innerHTML=data[i].teaNo;
                            sessionStorage.setItem("tea"+i,data[i].teaNo);
                            teaName.innerHTML=data[i].teaName;
                            teaPwd.innerHTML=data[i].teaPwd;
                            teaDl.innerHTML=data[i].teaDiscipline;
                            teaMail.innerHTML=data[i].teaMail;

                            teacher.appendChild(teaNo);
                            teacher.appendChild(teaName);
                            teacher.appendChild(teaPwd);
                            teacher.appendChild(teaDl);
                            teacher.appendChild(teaMail);

                            var button=document.getElementById("button").cloneNode(true);
                            var change=document.getElementById("change").cloneNode(true);
                            var del=document.getElementById("delete").cloneNode(true);
                            change.title="tea"+i;
                            del.title="tea"+i;

                            button.appendChild(change);
                            button.appendChild(del);
                            teacher.appendChild(button);

                            document.getElementById("teacherList0").appendChild(teacher);
                            var j=i+1;
                            document.getElementById("teacherNum").innerHTML=j;
                        }
                        else if (i==0){
                            sessionStorage.setItem('tea0',data[i].teaNo);
                            document.getElementById("teacherNum").innerHTML=1;
                            document.getElementById("teaNo0").innerHTML=data[0].teaNo;
                            document.getElementById("teaName0").innerHTML=data[0].teaName;
                            document.getElementById("teaPwd0").innerHTML=data[0].teaPwd;
                            document.getElementById("teaDl0").innerHTML=data[0].teaDiscipline;
                            document.getElementById("teaMail0").innerHTML=data[0].teaMail;
                        }
                    }
                    else break;
                }
                document.getElementById("teacherList").innerHTML=null;
                for (i=1;;i++){
                    if (data[i]){
                        document.getElementById("teacherList").appendChild(document.getElementById("tea"+i));
                    }
                    else break;
                }
                document.getElementById("teacherList0").innerHTML=null;
            },
            error: function (data) {
                console.log("请求失败");
            }
        });
    }
    function searchTeaByName(){
        var name=$("#teaName").val();
        $.ajax({
            url: "/teacher/getteabyteaname",
            type : "post",
            async: false,
            dataType: "json",
            data : {teaName:name},
            // contentType: "application/json",
            success: function (data) {
                console.log("请求成功");
                var i=0;
                for (;;i++){
                    if (data[i]){
                        if (i!==0){
                            var teacher=document.getElementById("teacher").cloneNode(true);
                            teacher.id="tea"+i;
                            var teaNo=document.getElementById("teaNo0").cloneNode(true);
                            var teaName=document.getElementById("teaName0").cloneNode(true);
                            var teaPwd=document.getElementById("teaPwd0").cloneNode(true);
                            var teaDl=document.getElementById("teaDl0").cloneNode(true);
                            var teaMail=document.getElementById("teaMail0").cloneNode(true);

                            teaNo.innerHTML=data[i].teaNo;
                            sessionStorage.setItem("tea"+i,data[i].teaNo);
                            teaName.innerHTML=data[i].teaName;
                            teaPwd.innerHTML=data[i].teaPwd;
                            teaDl.innerHTML=data[i].teaDiscipline;
                            teaMail.innerHTML=data[i].teaMail;

                            teacher.appendChild(teaNo);
                            teacher.appendChild(teaName);
                            teacher.appendChild(teaPwd);
                            teacher.appendChild(teaDl);
                            teacher.appendChild(teaMail);

                            var button=document.getElementById("button").cloneNode(true);
                            var change=document.getElementById("change").cloneNode(true);
                            var del=document.getElementById("delete").cloneNode(true);
                            change.title="tea"+i;
                            del.title="tea"+i;

                            button.appendChild(change);
                            button.appendChild(del);
                            teacher.appendChild(button);

                            document.getElementById("teacherList0").appendChild(teacher);
                            var j=i+1;
                            document.getElementById("teacherNum").innerHTML=j;
                        }
                        else if (i==0){
                            sessionStorage.setItem('tea0',data[i].teaNo);
                            document.getElementById("teacherNum").innerHTML=1;
                            document.getElementById("teaNo0").innerHTML=data[0].teaNo;
                            document.getElementById("teaName0").innerHTML=data[0].teaName;
                            document.getElementById("teaPwd0").innerHTML=data[0].teaPwd;
                            document.getElementById("teaDl0").innerHTML=data[0].teaDiscipline;
                            document.getElementById("teaMail0").innerHTML=data[0].teaMail;
                        }
                    }
                    else break;
                }
                document.getElementById("teacherList").innerHTML=null;
                for (i=1;;i++){
                    if (data[i]){
                        document.getElementById("teacherList").appendChild(document.getElementById("tea"+i));
                    }
                    else break;
                }
                document.getElementById("teacherList0").innerHTML=null;
            },
            error: function (data) {
                console.log("请求失败");
            }
        });
    }
    function searchTeaByDl(){
        var dl=$("#teaDl").val();
        $.ajax({
            url: "/teacher/getteabyteadis",
            type : "post",
            async: false,
            dataType: "json",
            data : {teaDiscipline:dl},
            // contentType: "application/json",
            success: function (data) {
                console.log("请求成功");
                var i=0;
                for (;;i++){
                    if (data[i]){
                        if (i!==0){
                            var teacher=document.getElementById("teacher").cloneNode(true);
                            teacher.id="tea"+i;
                            var teaNo=document.getElementById("teaNo0").cloneNode(true);
                            var teaName=document.getElementById("teaName0").cloneNode(true);
                            var teaPwd=document.getElementById("teaPwd0").cloneNode(true);
                            var teaDl=document.getElementById("teaDl0").cloneNode(true);
                            var teaMail=document.getElementById("teaMail0").cloneNode(true);

                            teaNo.innerHTML=data[i].teaNo;
                            sessionStorage.setItem("tea"+i,data[i].teaNo);
                            teaName.innerHTML=data[i].teaName;
                            teaPwd.innerHTML=data[i].teaPwd;
                            teaDl.innerHTML=data[i].teaDiscipline;
                            teaMail.innerHTML=data[i].teaMail;

                            teacher.appendChild(teaNo);
                            teacher.appendChild(teaName);
                            teacher.appendChild(teaPwd);
                            teacher.appendChild(teaDl);
                            teacher.appendChild(teaMail);

                            var button=document.getElementById("button").cloneNode(true);
                            var change=document.getElementById("change").cloneNode(true);
                            var del=document.getElementById("delete").cloneNode(true);
                            change.title="tea"+i;
                            del.title="tea"+i;

                            button.appendChild(change);
                            button.appendChild(del);
                            teacher.appendChild(button);

                            document.getElementById("teacherList0").appendChild(teacher);
                            var j=i+1;
                            document.getElementById("teacherNum").innerHTML=j;
                        }
                        else if (i==0){
                            sessionStorage.setItem('tea0',data[i].teaNo);
                            document.getElementById("teacherNum").innerHTML=1;
                            document.getElementById("teaNo0").innerHTML=data[0].teaNo;
                            document.getElementById("teaName0").innerHTML=data[0].teaName;
                            document.getElementById("teaPwd0").innerHTML=data[0].teaPwd;
                            document.getElementById("teaDl0").innerHTML=data[0].teaDiscipline;
                            document.getElementById("teaMail0").innerHTML=data[0].teaMail;
                        }
                    }
                    else break;
                }
                document.getElementById("teacherList").innerHTML=null;
                for (i=1;;i++){
                    if (data[i]){
                        document.getElementById("teacherList").appendChild(document.getElementById("tea"+i));
                    }
                    else break;
                }
                document.getElementById("teacherList0").innerHTML=null;
            },
            error: function (data) {
                console.log("请求失败");
            }
        });
    }
    function searchTeaByMail(){
        var mail=$("#teaMail").val();
        $.ajax({
            url: "/teacher/getteabyteamail",
            type : "post",
            async: false,
            dataType: "json",
            data : {teaMail:mail},
            // contentType: "application/json",
            success: function (data) {
                console.log("请求成功");
                var i=0;
                for (;;i++){
                    if (data[i]){
                        if (i!==0){
                            var teacher=document.getElementById("teacher").cloneNode(true);
                            teacher.id="tea"+i;
                            var teaNo=document.getElementById("teaNo0").cloneNode(true);
                            var teaName=document.getElementById("teaName0").cloneNode(true);
                            var teaPwd=document.getElementById("teaPwd0").cloneNode(true);
                            var teaDl=document.getElementById("teaDl0").cloneNode(true);
                            var teaMail=document.getElementById("teaMail0").cloneNode(true);

                            teaNo.innerHTML=data[i].teaNo;
                            sessionStorage.setItem("tea"+i,data[i].teaNo);
                            teaName.innerHTML=data[i].teaName;
                            teaPwd.innerHTML=data[i].teaPwd;
                            teaDl.innerHTML=data[i].teaDiscipline;
                            teaMail.innerHTML=data[i].teaMail;

                            teacher.appendChild(teaNo);
                            teacher.appendChild(teaName);
                            teacher.appendChild(teaPwd);
                            teacher.appendChild(teaDl);
                            teacher.appendChild(teaMail);

                            var button=document.getElementById("button").cloneNode(true);
                            var change=document.getElementById("change").cloneNode(true);
                            var del=document.getElementById("delete").cloneNode(true);
                            change.title="tea"+i;
                            del.title="tea"+i;

                            button.appendChild(change);
                            button.appendChild(del);
                            teacher.appendChild(button);

                            document.getElementById("teacherList0").appendChild(teacher);
                            var j=i+1;
                            document.getElementById("teacherNum").innerHTML=j;
                        }
                        else if (i==0){
                            sessionStorage.setItem('tea0',data[i].teaNo);
                            document.getElementById("teacherNum").innerHTML=1;
                            document.getElementById("teaNo0").innerHTML=data[0].teaNo;
                            document.getElementById("teaName0").innerHTML=data[0].teaName;
                            document.getElementById("teaPwd0").innerHTML=data[0].teaPwd;
                            document.getElementById("teaDl0").innerHTML=data[0].teaDiscipline;
                            document.getElementById("teaMail0").innerHTML=data[0].teaMail;
                        }
                    }
                    else break;
                }
                document.getElementById("teacherList").innerHTML=null;
                for (i=1;;i++){
                    if (data[i]){
                        document.getElementById("teacherList").appendChild(document.getElementById("tea"+i));
                    }
                    else break;
                }
                document.getElementById("teacherList0").innerHTML=null;
            },
            error: function (data) {
                console.log("请求失败");
            }
        });
    }

</script>

<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });

    /*用户-删除*/
    function member_del(obj,s){
        console.log(s);
        var teaNo=sessionStorage.getItem(s);
        console.log(teaNo);

        $.ajax({
            url: "/manager/deletetea",
            type : "post",
            async: false,
            dataType: "json",
            data : {teaNo:teaNo},

            success: function (data) {
                console.log('请求成功');
                if (data==1){
                    $(obj).parents("tr").remove();
                    alert("删除成功");}
                else alert("删除失败");
            },
            error: function (data) {
                console.log("请求失败");
            }
        });




    }



    // function delAll (argument) {
    //
    //     var data = tableCheck.getData();
    //
    //     layer.confirm('确认要删除吗？'+data,function(index){
    //         //捉到所有被选中的，发异步进行删除
    //         layer.msg('删除成功', {icon: 1});
    //         $(".layui-form-checked").not('.header').parents('tr').remove();
    //     });
    // }
</script>
</body>

</html>